<?php

include_once 'models/m_event.class.php';

class cImporter
{
	public static function Parse($data)
	{
		// $x = stripcslashes($XmlStr);
		$db = DB::get();
		if($data)
		{
			$x = simplexml_load_string($data);
			foreach ($x->event as $xe) 
			{
				$event = mEvent::Parse($xe);
				if($event->Save())
				{
					// сохраняем сведения о произведенной загрузке
					$event->Fix();
				}
			}
		}
	}

	private function Log($msg)
	{ 
		$ymd = date("Y-m-d", mktime());
		$fd = fopen("logs/sys.".$ymd.".log", "a+");
		$str  = date("H:i:s", mktime());
		$str .= "\t".$_SERVER['REMOTE_ADDR'];
		$str .= "\tpage_importer.php\t".$msg."\n";
		fwrite($fd, $str);
		fclose($fd);
	}
}